home *** CD-ROM | disk | FTP | other *** search
- /*
- *=============================================================================
- * tSippPPM.c
- *-----------------------------------------------------------------------------
- * Tcl commands to do SIPP rendering to PPM and PBM files.
- *-----------------------------------------------------------------------------
- * Copyright 1992 Mark Diekhans
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies. Mark Diekhans makes
- * no representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *-----------------------------------------------------------------------------
- * $Id: tSippPPM.c,v 2.0 1992/11/02 03:56:28 markd Rel $
- *=============================================================================
- */
-
- #include "tSippInt.h"
-
- /*=============================================================================
- * SippPPMRender --
- * Implements the command:
- * SippPPMRender fileid xsize ysize [mode] [oversample]
- * Note:
- * This procedure has standard Tcl command calling sematics. ClientData
- * contains a pointer to the Tcl SIPP global structure.
- *-----------------------------------------------------------------------------
- */
- static int
- SippPPMRender (clientData, interp, argc, argv)
- char *clientData;
- Tcl_Interp *interp;
- int argc;
- char **argv;
- {
- tSippGlob_pt tSippGlobPtr = (tSippGlob_pt) clientData;
- tSippRenderParms_t renderParms;
- OpenFile *ppmFilePtr;
-
- if (!TSippParseRenderParms (tSippGlobPtr, argc, argv, "fileid",
- &renderParms))
- return TCL_ERROR;
-
- if (TclGetOpenFile (interp, renderParms. fileHandle,
- &ppmFilePtr) != TCL_OK)
- return TCL_ERROR;
-
- if (!ppmFilePtr->writable) {
- Tcl_AppendResult (interp, "Output file is not open for writting",
- (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Make sure rendering is in the correct order.
- */
- sipp_render_direction (FALSE);
-
- if (renderParms.interlaced)
- render_field_file (renderParms.xSize,
- renderParms.ySize,
- ppmFilePtr->f,
- renderParms.mode,
- renderParms.overSampling,
- renderParms.field);
- else
- render_image_file (renderParms.xSize,
- renderParms.ySize,
- ppmFilePtr->f,
- renderParms.mode,
- renderParms.overSampling);
- return TCL_OK;
-
- } /* SippPPMRender */
-
- /*=============================================================================
- * TSippPPMInit --
- * Initialized the PPm and PBM rendering commands.
- *
- * Parameters:
- * o tSippGlobPtr (I) - Pointer to the top level global data structure.
- * (currently unused).
- *-----------------------------------------------------------------------------
- */
- void
- TSippPPMInit (tSippGlobPtr)
- tSippGlob_pt tSippGlobPtr;
- {
- static tSippTclCmdTbl_t cmdTable [] = {
- {"SippPPMRender", SippPPMRender},
- {NULL, NULL}
- };
-
- TSippInitCmds (tSippGlobPtr, cmdTable);
-
- } /* TSippPPMInit */
-